c52a045966a220f083e9217c7bd0db5a18078faf,servers/src/main/java/tachyon/worker/block/BlockMetadataManager.java,BlockMetadataManager,moveBlockMeta,#number#number#BlockStoreLocation#,152
Before Change
public synchronized Optional<BlockMeta> moveBlockMeta(long userId, long blockId,
BlockStoreLocation newLocation) {
// Check if the blockId is valid.
BlockMeta block = getBlockMeta(blockId).orNull();
if (block == null) {
LOG.error("No block found for block ID {}", blockId);
return Optional.absent();
}
// If move target can be any tier, then simply return the current block meta.
if (newLocation.equals(BlockStoreLocation.anyTier())) {
return Optional.of(block);
}
int newTierAlias = newLocation.tierAlias();
StorageTier newTier = getTier(newTierAlias);
StorageDir newDir = null;
if (newLocation.equals(BlockStoreLocation.anyDirInTier(newTierAlias))) {
for (StorageDir dir : newTier.getStorageDirs()) {
if (dir.getAvailableBytes() > block.getBlockSize()) {
newDir = dir;
}
}
} else {
newDir = newTier.getDir(newLocation.dir());
}
if (newDir == null) {
return Optional.absent();
}
StorageDir oldDir = block.getParentDir();
if (!oldDir.removeBlockMeta(block)) {
return Optional.absent();
}
return newDir.addBlockMeta(block);
}
/**
After Change
public synchronized BlockMeta moveBlockMeta(long blockId, BlockStoreLocation newLocation)
throws IOException {
// Check if the blockId is valid.
BlockMeta blockMeta = getBlockMeta(blockId);
// If move target can be any tier, then simply return the current block meta.
if (newLocation.equals(BlockStoreLocation.anyTier())) {